package com.chenqq.qsocket.handler;

import com.chenqq.qsocket.listener.SocketMessageListener;
import com.chenqq.qsocket.message.SocketMessage;

import org.apache.mina.core.session.IoSession;
import org.json.JSONException;


public class SocketMessageDispatcher {

	public void handleMessage(IoSession session, SocketMessage msg,String tag,SocketMessageListener listener) throws JSONException {
		int type = msg.getType();
		MessageHandler handler = MessageHandlerFactory.getHandler(type);
		handler.handleListener(tag,listener);
		handler.handleMessage(msg, session);
	}
}
